package com.google.code.jmarias.common.action;

import com.google.code.jmarias.common.AbstractUser;
import com.google.code.jmarias.common.NewTable;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * Predstavuje prijatou zpravu s informaci o autorovi. Odesilatel neuvadi info
 * o sobe, mohl by podvrhnout cizi, ale informace se doplnuje az na serveru.
 *
 * Odesilatel null znamena, ze zpravu vytvoril server.
 * @author Ondrej Michal
 */
@XmlRootElement
public class SignedAction extends AbstractSignedMessage {

    private AbstractAction rawAction;

    public SignedAction() {
    }

    /** Akce od serveru */
    public SignedAction(AbstractAction rawAction) {
        this.rawAction = rawAction;
    }

    public SignedAction(AbstractUser sender, AbstractAction rawAction) {
        super(sender);
        this.rawAction = rawAction;
    }

    public void updateTable(NewTable table) {
        ((GameAction)rawAction).updateTable(table, getSender());
    }

    @Override
    public String toString() {
        return "akce od " + getSender() + ": " + rawAction;
    }

    public AbstractAction getRawAction() {
        return rawAction;
    }

    public void setRawAction(AbstractAction rawAction) {
        this.rawAction = rawAction;
    }

}
